package cn.tiasen.helloworld;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    private Button btn_1;
    private Button btn_login;
    private Button btn_radio;
    private Button btn_image;
    private Button btn_page_params;
    private Button btn_call_sms;
    private Button btn_menu;
    private Button btn_progress;
    private Button btn_dialog;
    private Button btn_applist;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btn_1 = findViewById(R.id.bth_1);

        btn_login = findViewById(R.id.btn_login);
        btn_radio = findViewById(R.id.btn_radio);
        btn_image = findViewById(R.id.btn_image);
        btn_page_params = findViewById(R.id.btn_page_params);
        btn_call_sms = findViewById(R.id.btn_call_sms);
        btn_menu = findViewById(R.id.btn_menu);
        btn_progress = findViewById(R.id.btn_progress);
        btn_dialog = findViewById(R.id.btn_dialog);
        btn_applist = findViewById(R.id.btn_applist);
        clickListener();
    }

    private void clickListener(){
        btn_1.setOnClickListener(new OnClick());
        btn_login.setOnClickListener(new OnClick());
        btn_radio.setOnClickListener(new OnClick());
        btn_image.setOnClickListener(new OnClick());
        btn_page_params.setOnClickListener(new OnClick());
        btn_call_sms.setOnClickListener(new OnClick());
        btn_menu.setOnClickListener(new OnClick());
        btn_progress.setOnClickListener(new OnClick());
        btn_dialog.setOnClickListener(new OnClick());
        btn_applist.setOnClickListener(new OnClick());
    }

    private class OnClick implements View.OnClickListener {

        @Override
        public void onClick(View v) {
            Intent intent = null;
            switch (v.getId()){
                case R.id.bth_1:
                    intent = new Intent(MainActivity.this,ButtonActivity.class);
                    break;
                case R.id.btn_login:
                    intent = new Intent(MainActivity.this,LoginActivity.class);
                    break;
                case R.id.btn_radio:
                    intent = new Intent(MainActivity.this,RadioActivity.class);
                    break;
                case R.id.btn_image:
                    intent = new Intent(MainActivity.this,ImageActivity.class);
                    break;
                case R.id.btn_page_params:
                    intent = new Intent(MainActivity.this,Page1Activity.class);
                    break;
                case R.id.btn_call_sms:
                    intent = new Intent(MainActivity.this,CallSmsActivity.class);
                    break;
                case R.id.btn_menu:
                    intent = new Intent(MainActivity.this,MenuActivity.class);
                    break;
                case R.id.btn_progress:
                    intent = new Intent(MainActivity.this,ProgressBarActivity.class);
                    break;
                case R.id.btn_dialog:
                    intent = new Intent(MainActivity.this,DialogActivity.class);
                    break;
                case R.id.btn_applist:
                    intent = new Intent(MainActivity.this,AppListActivity.class);
                    break;
            }
            startActivity(intent);
        }
    }

    public void mobileGuard(View v){
        Intent intent = new Intent(this,MobileGuardActivity.class);
        startActivity(intent);

    }
}
